package cn.lf.android.lawfirm.outgoingregistration;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import cn.lf.android.lawfirm.BaseActivity;
import cn.lf.android.lawfirm.R;
import cn.lf.android.lawfirm.outgoingregistration.controller.OutGoingInfoConroller;
import cn.lf.android.lawfirm.outgoingregistration.modle.OutGoingInfo;

/**
 * 外出登记详情
 * Created by Administrator on 2017/8/22.
 */

public class OutGoingInfoActivity extends BaseActivity implements OutGoingInfoConroller.OutGoingInfoCallback {
    /**
     * 外出日期
     **/
    private TextView mData;
    /**
     * 起始时间
     **/
    private TextView mBeginTime;
    /**
     * 结束时间
     **/
    private TextView mEndTime;
    /**
     * 外出地点
     **/
    private TextView mAddress;
    /**
     * 外出事项
     **/
    private TextView mMatters;
    /**
     * 外出时长
     **/
    private TextView timespan;
    /**
     * 外出人
     **/
    private TextView lsysUserName;
    private ImageView mLeft;
    private TextView mTitle;
    private String id = "0";
    private OutGoingInfoConroller mOutGoingInfoConroller;

    @Override
    public Object getContentResView() {
        return R.layout.activity_outgoinginfo;
    }

    @Override
    public void initView() {
        initTitle();
        Intent intent = getIntent();
        id = intent.getStringExtra("id");
        mData = ((TextView) findViewById(R.id.content_data));
        mBeginTime = ((TextView) findViewById(R.id.content_begintime));
        mEndTime = ((TextView) findViewById(R.id.content_endtime));
        mAddress = ((TextView) findViewById(R.id.content_address));
        mMatters = ((TextView) findViewById(R.id.et_matters));
        timespan = ((TextView) findViewById(R.id.timespan));
        lsysUserName = ((TextView) findViewById(R.id.lsysUserName));
    }

    private void initTitle() {
        mLeft = ((ImageView) findViewById(R.id.img_left));
        mLeft.setVisibility(View.VISIBLE);
        mLeft.setOnClickListener(this);
        mTitle = ((TextView) findViewById(R.id.eb_tv_title));
        mTitle.setText("外出详情");
    }

    @Override
    public void initData() {
        mOutGoingInfoConroller = new OutGoingInfoConroller(this, this);
        mOutGoingInfoConroller.onOutGoingInfo(id);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.img_left:
                finish();
                break;
        }
    }

    OutGoingInfo mBean;

    @Override
    public void onOutGoingInfouccessed(OutGoingInfo beans) {
        mBean = beans;
        mBeginTime.setText(beans.startTime);
        mEndTime.setText(beans.endTime);
        mAddress.setText(beans.destination);
        mMatters.setText(beans.reason);
        timespan.setText(beans.timespan + "小时");
        lsysUserName.setText(beans.LsysUserName);
    }

    @Override
    public void onOutGoingInfoFailed() {

    }
}
